package com.market2.utils.converter.impl;

import com.market2.dto.SocieteDto;
import com.market2.model.Societe;
import com.market2.utils.converter.Converter;

public class SocieteConverter extends Converter
{
	@SuppressWarnings("unchecked")
	public SocieteDto convertTo(Object entry)
	{
		if(entry == null || !(entry instanceof Societe)) {
			return null;
		}
		
		SocieteDto result = new SocieteDto();
		Societe societe = (Societe) entry;
		
		result.setNom(societe.getNom());
		result.setDateCreation(societe.getDateCreation());
		result.setSecteur(societe.getSecteur());
		result.setAdresse(societe.getAdresse());
		result.setEmail(societe.getEmail());
		result.setTelephone(societe.getTelephone());
		result.setStatus(societe.getStatus());
		
		return result;
	}

	@SuppressWarnings("unchecked")
	public com.market2.model.Societe convertFrom(Object source)
	{
		if(source == null || !(source instanceof SocieteDto)) {
			return null;
		}
		
		SocieteDto societe = (SocieteDto) source;
		Societe result = new Societe();
		
		result.setNom(societe.getNom());
		result.setDateCreation(societe.getDateCreation());
		result.setSecteur(societe.getSecteur());
		result.setAdresse(societe.getAdresse());
		result.setEmail(societe.getEmail());
		result.setTelephone(societe.getTelephone());
		result.setStatus(societe.getStatus());
		
		return result;
	}
}
